/**
 * Copyright 2010 Paulo Alem 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package flatfile.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import flatfile.Converter;

/**
 * 
 * @author paulo
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Column {

	/**
	 * Defines the beginning of a field
	 */
	int start() default 0;

	/**
	 * Defines where the field ends. If its less than zero, only the start is
	 * taken in consideration to extract the column. That means that the
	 * extracted column will start at start and end at the string last char
	 */
	int end() default -1;

	/**
	 * Specifies a specific class to do the data conversion. By default only
	 * really simple types are handled. If you need something more sophisticated
	 * you will probably need a converter. Null is not allowed and this DEFAULT
	 * class workaround had to be done
	 */
	Class<? extends Converter> converter() default DEFAULT.class;

	static final class DEFAULT implements Converter {
		@Override
		public Object convert(String s, Class cls) {
			throw new UnsupportedOperationException(
					"Dummy class, dont use me directly");
		}
	};
}
